package com.sanyuemaomao.dict;

import aframe.Config;
import aframe.http.Http;
import aframe.http.bean.HttpParam;
import aframe.http.bean.HttpTask;
import aframe.http.callback.HttpCallBack;
import aframe.utils.LogUtils;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {

	private TextView tv;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		tv=(TextView)findViewById(R.id.tv);

		Config.setFrameWorkConfig(true, "gp", true);

		HttpTask task = new HttpTask();
		task.setUrl("http://dict-co.iciba.com/api/dictionary.php");
		task.setMethod(Http.GET);
		task.setTaskType(1);

		HttpParam hp = new HttpParam();
		hp.add("w", "go");
		hp.add("key", "03A6237D184654335142E59F4B36841B");

		task.setParam(hp);

		Http.doTask(task, new HttpCallBack() {

			@Override
			public void callBack(final HttpTask task) {
				runOnUiThread(new Runnable() {

					@Override
					public void run() {
						String data = task.getData();
						tv.setText(data);
						LogUtils.log(data);
					}
				});
			}
		});

	}
}
